import Mock from 'mockjs'
const category = Mock.mock({
    'list|10': [{
        "id|+1": 1,
        "categoryName": "辅料分类@id"
    }]
})
const bom = Mock.mock({
    'list|30': [{
        "id|+1": 1,
        "bomCode|+1": '0000'+ 1,
        "bomName": "辅料名称@id",
        "bomCategory": "@id",
        "bomct": "",
        "bomMinQty": "",
        "bomProductTime": "@date()",
        "wareName": "",
        "Qty": "",
        "price": "",
        "bomUnit": "kg",
        "bomSupplier": "供应商@id",
        "bom": "",
        "bomColor|1": ["红色", "蓝色", "黑色", "绿色", "黄色"],
        "bomSpecial": "",
        "bomSerrialNO": "",
        "bomSeialName": "",
        "bomIocNO": "",
        "bomIocCode": "",
        "bomStrayCode": "",
        "bomBatchCode": "",
        "bomProviderId": "",
        "bomReceiverId": "",
        "bomOwnerId": "",
        "bomQty": "",
        "recovery": "",
        "bomWeight": "",
        "ratiomin": "",
        "priceNode": "",
        "bomstanrd": "",
        "bomRemark": ""
    }]
})
export default [

    // 商品分类
    {
        url: '/bom/category/getAll',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                data: category.list
            }
        }
    },
    //获取商品信息列表
    {
        url: '/bom/getPageList',
        type: 'post',
        response: config => {
            let { pageSize = 10, currentPage = 1 } = config.body
            const total = bom.list.length
            let list = bom.list.slice(pageSize * (currentPage - 1), currentPage * pageSize)
            return {
                code: 20000,
                data: {
                    list,
                    currentPage,
                    pageSize,
                    totalCount: total,
                    totalPages: (total + pageSize - 1) / pageSize,
                }
            }
        }
    },
    //删除商品
    {
        url: '/bom/del',
        type: 'post',
        response: config => {
            const { id } = config.body
            if (!id) {
                return {
                    code: 403,
                    msg: '删除失败',
                    data: null
                }
            }
            return {
                code: 20000,
                msg: '处理成功',
                data: id
            }
        }
    },
    //新增商品
    {
        url: '/bom/add',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                msg: '新增成功',
            }
        }
    },
    //修改商品
    {
        url: '/bom/editor',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                msg: '修改成功',
            }
        }
    },
]